﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MotionControl;
using System.Diagnostics;
using System.Threading;

namespace MainFrame
{
    public partial class FormAlarm : Form
    {
        //CardMotion cardm;
        //public delegate void laminateDelegate(int m);
        //laminateDelegate laminateDel;
        //bool totalError = false;
        public FormAlarm()
        {
            InitializeComponent();
        }

        private void btn_OK_Click(object sender, EventArgs e)
        {           
            this.Close();
            clearInfo();
            GlobalMotion.mainCard.setOut((ushort)e_light_IO.yellow, e_out_OnOff.off);//取消黄灯报警
        }

        private void updateDisplay()
        {
            if (GlobalVar.warningTips[(int)GlobalVar.warningType.noData].haveInfo)
            {
                lbl_DataReady.Text = "是";
                lbl_DataReady.ForeColor = System.Drawing.Color.Red;
            }
            if (GlobalVar.warningTips[(int)GlobalVar.warningType.changeSandPaper].haveInfo)
            {
                lbl_sandPaper.Text = "是";
                lbl_sandPaper.ForeColor = System.Drawing.Color.Red;
            }
            if (GlobalVar.warningTips[(int)GlobalVar.warningType.changeAM].haveInfo)
            {
                lbl_needChangeAM.Text = "是";
                lbl_needChangeAM.ForeColor = System.Drawing.Color.Red;
            }
            if (GlobalVar.warningTips[(int)GlobalVar.warningType.sucker].haveInfo)
            {
                lbl_sucker.Text = GlobalVar.warningTips[(int)GlobalVar.warningType.sucker].Info;
                lbl_sucker.ForeColor = System.Drawing.Color.Red;
            }
            if (GlobalVar.warningTips[(int)GlobalVar.warningType.complete].haveInfo)
            {
                lbl_CompletePlan.Text = "是";
                lbl_CompletePlan.ForeColor = System.Drawing.Color.Green;
            }
 
        }
        private void clearInfo()
        {
            //totalError = false;
            GlobalVar.warningTips[(int)GlobalVar.warningType.noData].haveInfo = false;
            GlobalVar.warningTips[(int)GlobalVar.warningType.complete].haveInfo = false;
            GlobalVar.warningTips[(int)GlobalVar.warningType.changeSandPaper].haveInfo = false;
            GlobalVar.warningTips[(int)GlobalVar.warningType.changeAM].haveInfo = false;
            GlobalVar.warningTips[(int)GlobalVar.warningType.sucker].haveInfo = false;
            GlobalVar.warningTips[(int)GlobalVar.warningType.sucker].Info = "";
            lbl_CompletePlan.Text = "";
            lbl_DataReady.Text = "";
            lbl_needChangeAM.Text = "";
            lbl_sandPaper.Text = "";
            lbl_sucker.Text = "";
        }

        private void FormAlarm_Load(object sender, EventArgs e)
        {
            GlobalMotion.mainCard.setOut((ushort)e_light_IO.yellow, e_out_OnOff.on);//设置黄灯报警
            GlobalMotion.mainCard.setOut((ushort)e_light_IO.red, e_out_OnOff.off);//取消绿灯
            GlobalMotion.mainCard.setOut((ushort)e_light_IO.green, e_out_OnOff.off);//取消红灯报警

            GlobalVar.isPause = true;//暂停
            GlobalVar.isAutoRun = false;//自动运行停止 
            GlobalVar.isAlarmPopup = true;
            updateDisplay();
        }

        private void FormAlarm_FormClosed(object sender, FormClosedEventArgs e)
        {
            GlobalVar.isAlarmPopup = false;
        }
    }
}
